package com.scalar.chiptrack.adaptor.osep;

import com.scalar.chiptrack.jobs.JobHandler;
import com.scalar.chiptrack.adaptor.AdaptorConstants;
import com.scalar.chiptrack.adaptor.AdaptorUtils;
import com.scalar.chiptrack.adaptor.AssemblyLot;
import com.scalar.chiptrack.adaptor.TestLot;
import com.scalar.chiptrack.adaptor.InventoryLot;
import com.scalar.chiptrack.adaptor.dao.*;
import com.scalar.chiptrack.utils.Logger;
import com.scalar.chiptrack.db.DBTransaction;
import com.scalar.ScalarException;

import java.util.HashMap;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Calendar;

import java.io.File;

import jxl.Workbook;
import jxl.Sheet;
import jxl.Cell;
import jxl.CellType;

/**
 *
 */

public class OSEPDataParser extends JobHandler implements AdaptorConstants
{
    HashMap m_assemblyDataMap           = new HashMap();
    HashMap m_ftDataMap               = new HashMap();
    HashMap m_fgInvDataMap              = new HashMap();
    HashMap m_tapereelDataMap           = new HashMap();
    private Logger m_parserLogger       = null;
    private String m_dataOutputDir      = null;
    private DBTransaction dbTransaction = null;

    Calendar cal = Calendar.getInstance();
    int thisYear = cal.get( Calendar.YEAR );
    int thisMonth = cal.get( Calendar.MONTH ) + 1 ;

    public OSEPDataParser() throws ScalarException
    {
        try
        {
            m_dataOutputDir = AdaptorUtils.getDataOutputDir(VENDOR_NAME_OSEP, WIP_TYPE_ASSEMBLY);
            AdaptorUtils.makeAllAdaptorDirs(m_dataOutputDir);
            m_parserLogger = AdaptorUtils.getDataParserLogger(m_dataOutputDir,VENDOR_NAME_OSEP);
            AssemblyAdaptorDAO.setLogger(m_parserLogger);
            InventoryLotDAO.setLogger(m_parserLogger);
            TestAdaptorDAO.setLogger(m_parserLogger);
            OsepDAO.setLogger(m_parserLogger);
            AdaptorUtils.setLogger(m_parserLogger);
        }
        catch (ScalarException se)
        {
            log("ERROR!! ERROR!! ERROR!! Exception while loading OSEP WIP output directory details from database, Exception: " + se);
            throw se;
        }
    }

    public static void main(String args[]) throws Exception
    {
       new OSEPDataParser().execute();
    }


    public void execute() throws Exception
    {
        AdaptorUtils.printHeader(VENDOR_NAME_OSEP + " WIP", CONSTANT_PARSER);

        File doneDestDir = new File(m_dataOutputDir + "/done");

        File wipDataoutDir = new File(m_dataOutputDir);

        File[] fileList = wipDataoutDir.listFiles();

        if ((fileList == null) || (fileList.length <= 3))
        {
            log("No file found in directory: " + wipDataoutDir);
            throw new ScalarException("No file found in directory: " + wipDataoutDir + "----\n\n");
        }

        ArrayList allWipLotList = null;
        ArrayList successFileList = new ArrayList();
        boolean success = false;

        //PARSING STARTS FROM HERE
        for (int i = 0; i < fileList.length; i++)
        {
            if (fileList[i].isDirectory() == true)
            {
                continue;
            }

            if (fileList[i].getName() != null && ( fileList[i].getName().trim().startsWith(OSEPPOP3Adaptor.FILE_NAME_WIP ) ) )
            {
                try
                {
                    allWipLotList = parseOSEPWip( fileList[i].getAbsolutePath(), "OSEP WIP REPORT" );

                    if (allWipLotList != null && allWipLotList.size() > 0)
                    {
                        getWipStatusInfoList(allWipLotList);
                    }

                   ArrayList allDDPIWipLotList = parseOSEPDDPIWip( fileList[i].getAbsolutePath(), "DDPI WIP REPORT" );

                    if (allDDPIWipLotList != null && allDDPIWipLotList.size() > 0)
                    {
                        getDDPIWipStatusInfoList(allDDPIWipLotList);
                    }
                    //Add files to success list to move to /done directory
                    successFileList.add(fileList[i]);
                }
                catch( Exception e )
                {
                    success = false;
                    log("Exception while parsing file: " + fileList[i].getAbsolutePath() + "\nException: " + e);
                    e.printStackTrace();
                    throw e;
                }
            }
            /*if (fileList[i].getName() != null && ( fileList[i].getName().trim().startsWith(OSEPPOP3Adaptor.DDI_FILE_NAME_WIP )
                    || fileList[i].getName().trim().startsWith("OSEP WIP Report") ) )
            {
                try
                {

                    allWipLotList = parseOSEPDDPIWip( fileList[i].getAbsolutePath() );

                    if (allWipLotList != null && allWipLotList.size() > 0)
                    {
                        getDDPIWipStatusInfoList(allWipLotList);
                    }
                    //Add files to success list to move to /done directory
                    successFileList.add(fileList[i]);
                }
                catch( Exception e )
                {
                    success = false;
                    log("Exception while parsing file: " + fileList[i].getAbsolutePath() + "\nException: " + e);
                    e.printStackTrace();
                    throw e;
                }
            }*/
        }

        /*Updating the Assembly Lot Information*/
        try
        {
            // Step 2
            // Save Assembly Information
            if (m_assemblyDataMap.isEmpty() == false)
            {
                log(" Updating Assembly Lot Information");
                AssemblyAdaptorDAO.saveAssemblyLot(null, m_assemblyDataMap.values().iterator(), WIP_TYPE_ASSEMBLY, VENDOR_NAME_OSEP);
            }
            else
            {
                AssemblyAdaptorDAO.closeAssemblyLot(dbTransaction, WIP_TYPE_ASSEMBLY, VENDOR_NAME_OSEP);
            }

            m_assemblyDataMap.clear();
            m_assemblyDataMap = null;
            success = true;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log("ERROR!! ERROR!! ERROR!! Could not update Assembly Lot information into database: " + se);
            throw se;
        }
        /*Updating the Test Lot Information*/
        try
        {
            // Step 3
            // Save Test Information
            if (m_ftDataMap.isEmpty() == false)
            {
                log(" Updating Test Lot Information");
                TestAdaptorDAO.saveTestLot(null, m_ftDataMap.values().iterator(), LOCATION_TYPE_FT, VENDOR_NAME_OSEP);
            }
            else
            {
                TestAdaptorDAO.closeTestLot(dbTransaction, LOCATION_TYPE_FT, VENDOR_NAME_OSEP);
            }
            m_ftDataMap.clear();
            m_ftDataMap = null;
            success = true;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log("ERROR!! ERROR!! ERROR!! Could not update Test Lot information into database: " + se);
            throw se;
        }

        //Updating the OSEP Tape and Reel Lot Information*/
        try
        {
            // Step 2
            // Save Class Store Information
            if (m_tapereelDataMap.isEmpty() == false)
            {
                log(" Updating OSEP Tape and Reel Lot Information");
                InventoryLotDAO.saveInventoryLot(null, m_tapereelDataMap.values().iterator(), LOCATION_TYPE_TAPE_REEL, VENDOR_NAME_OSEP);
            }
            else
            {
                InventoryLotDAO.closeInventoryLot(dbTransaction, LOCATION_TYPE_TAPE_REEL, VENDOR_NAME_OSEP);
            }
            m_tapereelDataMap.clear();
            m_tapereelDataMap = null;
            success = true;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log("ERROR!! ERROR!! ERROR!! Could not update Tape and Reel Lot information into database: " + se);
            throw se;
        }


        //Updating the OSEP FG Lot Information*/
        try
        {
            // Step 2
            // Save Finished Goods Information
            if (m_fgInvDataMap.isEmpty() == false)
            {
                log(" Updating OSEP Finished Goods Lot Information");
                InventoryLotDAO.saveInventoryLot(null, m_fgInvDataMap.values().iterator(), LOCATION_TYPE_FG, VENDOR_NAME_OSEP);
            }
            else
            {
                InventoryLotDAO.closeInventoryLot(dbTransaction, LOCATION_TYPE_FG, VENDOR_NAME_OSEP);
            }
            m_fgInvDataMap.clear();
            m_fgInvDataMap = null;
            success = true;
        }
        catch (ScalarException se)
        {
            success = false;
            se.printStackTrace();
            log("ERROR!! ERROR!! ERROR!! Could not update Finished Goods Lot information into database: " + se);
            throw se;
        }

        // TO SEND THE NEW LOTS, NEW TRANSIT LOTS, NO PO LOTS, DISCREPANCY LOTS NOTIFICATIONS TO THE USER
        AdaptorDAO.sendAllNotifications(VENDOR_NAME_OSEP, true, true, true);

        // To Close All Drop Out Lots
        AdaptorDAO.closeDropOutLots(VENDOR_NAME_OSEP);

        int adaptor_id = AdaptorRunInfo.getLastRunAdaptorId( OSEPPOP3Adaptor.ADAPTOR_NAME, CONSTANT_ADAPTOR);

        // Update Adaptor_Run_Info table
        try
        {
            if ( success == true )
            {
                AdaptorRunInfo.saveAdaptorLastUpdatedStatus(CONSTANT_PARSER, OSEPPOP3Adaptor.ADAPTOR_NAME, CONSTANT_SUCCESS, adaptor_id);
                System.out.println( "SUCCESSFULLY UPDATED IN THE DATABASE" );
            }
        }
        catch ( ScalarException se )
        {
            success = false; //As filES DATA SAVED , UPDATEING AS SUCCESS
            AdaptorRunInfo.saveAdaptorLastUpdatedStatus(CONSTANT_PARSER, OSEPPOP3Adaptor.ADAPTOR_NAME, CONSTANT_SUCCESS, adaptor_id);
            log( "WARNING!! WARNING!! WARNING!! Could not update Adaptor run information, Exception: " + se );
            throw se;
        }
       // Step 7
       // Move the successful files to 'done' directory
       if ( success )
       {              
           AdaptorUtils.moveFilesToDone(successFileList, doneDestDir );
       }
    }//end of execute method

    /**
    *
    * @param allWipLotList
    */
    public void getWipStatusInfoList( ArrayList allWipLotList )  throws Exception
    {
        String partNumber            = null;
        String lotNumber             = null;
        String fablotNumber          = null;
        OSEPWipStatus osepWipStatus  = null;
        AssemblyLot assemblyLot      = null;
        TestLot     testLot          = null;
        InventoryLot inventoryLot    = null;
        String fgPartNumber          = null;

        int fgQqtyIn     = 0;


        try
        {
            Iterator osepIterator = allWipLotList.iterator();

            while (osepIterator.hasNext())
            {
                osepWipStatus = (OSEPWipStatus) osepIterator.next();

                fgPartNumber    = osepWipStatus.getDevice();
                lotNumber       = osepWipStatus.getLotNo();
                fablotNumber    = osepWipStatus.getFabLotNo();
                if (fablotNumber == null)
                {
                   fablotNumber = lotNumber;
                }
                try
                {
                    fgQqtyIn = Integer.parseInt(osepWipStatus.getFgBal() );
                }
                catch ( NumberFormatException ignore )
                {
                    fgQqtyIn = 0;
                }

                String dateIn    = null;
                String assyExpdateOut = null;
                if ( osepWipStatus.getInputDate() != null && osepWipStatus.getInputDate().trim().length() < 8 )
                {
                    String[] inputDate = osepWipStatus.getInputDate().split("/");
                    int Month = Integer.parseInt( inputDate[0] );
                    if ( Month > thisMonth )
                    {
                        dateIn = osepWipStatus.getInputDate() + "/" + ( thisYear-1);
                    }
                    else
                    {
                        dateIn = osepWipStatus.getInputDate() + "/" + thisYear;
                    }
                }
                if ( dateIn == null && osepWipStatus.getRcvdDate() != null && osepWipStatus.getRcvdDate().trim().length() < 8 )
                {
                    String[] recDate = osepWipStatus.getRcvdDate().split("/");
                    int Month = Integer.parseInt( recDate[0] );
                    if ( Month > thisMonth )
                    {
                        dateIn = osepWipStatus.getRcvdDate() + "/" + ( thisYear-1);
                    }
                    else
                    {
                        dateIn = osepWipStatus.getRcvdDate() + "/" + thisYear;
                    }
                }
                if (osepWipStatus.getAssyODate() != null && osepWipStatus.getAssyODate().trim().length() < 8 )
                {
                    String[] recDate = osepWipStatus.getAssyODate().split("/");
                    int Month = Integer.parseInt( recDate[0] );
                    if ( Month > thisMonth )
                    {
                        assyExpdateOut = osepWipStatus.getAssyODate() + "/" + ( thisYear-1);
                    }
                    else
                    {
                        assyExpdateOut = osepWipStatus.getAssyODate() + "/" + thisYear;
                    }
                }
                String releaseNumber = null;
                if ( fgPartNumber != null && lotNumber != null )
                {
                    /*Fetching Assembly Lots*/

                    if (  osepWipStatus.getStock() != null && osepWipStatus.getStock().equalsIgnoreCase("0") == false
                            || osepWipStatus.getVisualInspection() != null && osepWipStatus.getVisualInspection().equalsIgnoreCase("0") == false
                            || osepWipStatus.getDieAttach() != null && osepWipStatus.getDieAttach().equalsIgnoreCase("0") == false
                            || osepWipStatus.getWireBond() != null && osepWipStatus.getWireBond().equalsIgnoreCase("0") == false
                            || osepWipStatus.getPreMoldInspection() != null && osepWipStatus.getPreMoldInspection().equalsIgnoreCase("0") == false
                            || osepWipStatus.getMolding() != null && osepWipStatus.getMolding().equalsIgnoreCase("0") == false
                            || osepWipStatus.getPostMoldCure() != null && osepWipStatus.getPostMoldCure().equalsIgnoreCase("0") == false
                            || osepWipStatus.getDejunkTrim() != null && osepWipStatus.getDejunkTrim().equalsIgnoreCase("0") == false
                            || osepWipStatus.getSolderPlating() != null && osepWipStatus.getSolderPlating().equalsIgnoreCase("0") == false
                            || osepWipStatus.getFormSingulation() != null && osepWipStatus.getFormSingulation().equalsIgnoreCase("0") == false)
                    {

                        partNumber = NewAdaptorDAO.getPartNumber(fgPartNumber, WIP_TYPE_ASSEMBLY, WIP_TYPE_ASSEMBLY);

                        if (partNumber == null)
                        {
                            partNumber = fgPartNumber;
                        }

                        
                        if ( lotNumber.indexOf("-") != -1 )
                        {
                            releaseNumber = lotNumber.substring(0, lotNumber.indexOf("-") );
                        }
                        else
                        {
                            releaseNumber =  lotNumber;
                        }
                        
                        int releaseCount = AdaptorDAO.getApprovedAssemblyReleaseLot( releaseNumber, partNumber, VENDOR_NAME_OSEP );

                        if ( releaseCount > 0 )
                        {
                            AdaptorDAO.updateAssemblyReleaseStatus( releaseNumber );
                        }

                        assemblyLot = (AssemblyLot)m_assemblyDataMap.get( lotNumber + partNumber );

                        if (assemblyLot == null)
                        {
                            assemblyLot = new AssemblyLot(VENDOR_NAME_OSEP);
                            m_assemblyDataMap.put(lotNumber + partNumber, assemblyLot);
                        }

                        if (osepWipStatus.getStock() != null && osepWipStatus.getStock().equalsIgnoreCase("0") == false)
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(lotNumber + partNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + Integer.parseInt(osepWipStatus.getStock())) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(osepWipStatus.getStock());
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(osepWipStatus.getStock());
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", STOCK");
                            }
                            else
                            {
                                assemblyLot.setStage("STOCK");
                            }
                        }
                        if (osepWipStatus.getVisualInspection() != null && osepWipStatus.getVisualInspection().equalsIgnoreCase("0") == false)
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(lotNumber + partNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + Integer.parseInt(osepWipStatus.getVisualInspection())) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(osepWipStatus.getVisualInspection());
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(osepWipStatus.getVisualInspection());
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", Visual Inspection");
                            }
                            else
                            {
                                assemblyLot.setStage("Visual Inspection");
                            }
                        }
                        if (osepWipStatus.getDieAttach() != null && osepWipStatus.getDieAttach().equalsIgnoreCase("0") == false)
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(lotNumber + partNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + Integer.parseInt(osepWipStatus.getDieAttach())) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(osepWipStatus.getDieAttach());
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(osepWipStatus.getDieAttach());
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", Die Attach");
                            }
                            else
                            {
                                assemblyLot.setStage("Die Attach");
                            }

                        }
                        if (osepWipStatus.getWireBond() != null && osepWipStatus.getWireBond().equalsIgnoreCase("0") == false)
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(lotNumber + partNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + Integer.parseInt(osepWipStatus.getWireBond())) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(osepWipStatus.getWireBond());
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(osepWipStatus.getWireBond());
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", Wire Bond");
                            }
                            else
                            {
                                assemblyLot.setStage("Wire Bond");
                            }
                        }
                        if (osepWipStatus.getPreMoldInspection() != null && osepWipStatus.getPreMoldInspection().equalsIgnoreCase("0") == false)
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(lotNumber + partNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + Integer.parseInt(osepWipStatus.getPreMoldInspection())) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(osepWipStatus.getPreMoldInspection());
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(osepWipStatus.getPreMoldInspection());
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", PreMold Inspection");
                            }
                            else
                            {
                                assemblyLot.setStage("PreMold Inspection");
                            }
                        }
                        if (osepWipStatus.getMolding() != null && osepWipStatus.getMolding().equalsIgnoreCase("0") == false)
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(lotNumber + partNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + Integer.parseInt(osepWipStatus.getMolding())) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(osepWipStatus.getMolding());
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(osepWipStatus.getMolding());
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", Molding");
                            }
                            else
                            {
                                assemblyLot.setStage("Molding");
                            }
                        }
                        if (osepWipStatus.getPostMoldCure() != null && osepWipStatus.getPostMoldCure().equalsIgnoreCase("0") == false)
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(lotNumber + partNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + Integer.parseInt(osepWipStatus.getPostMoldCure())) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(osepWipStatus.getPostMoldCure());
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(osepWipStatus.getPostMoldCure());
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", Post Mold Cure");
                            }
                            else
                            {
                                assemblyLot.setStage("Post Mold Cure");
                            }
                        }
                        if (osepWipStatus.getDejunkTrim() != null && osepWipStatus.getDejunkTrim().equalsIgnoreCase("0") == false)
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(lotNumber + partNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + Integer.parseInt(osepWipStatus.getDejunkTrim())) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(osepWipStatus.getDejunkTrim());
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(osepWipStatus.getDejunkTrim());
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", Dejunk Trim");
                            }
                            else
                            {
                                assemblyLot.setStage("Dejunk Trim");
                            }
                        }
                        if (osepWipStatus.getSolderPlating() != null && osepWipStatus.getSolderPlating().equalsIgnoreCase("0") == false)
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(lotNumber + partNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + Integer.parseInt(osepWipStatus.getSolderPlating())) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(osepWipStatus.getSolderPlating());
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(osepWipStatus.getSolderPlating());
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", Solder Plating");
                            }
                            else
                            {
                                assemblyLot.setStage("Solder Plating");
                            }
                        }
                         if (osepWipStatus.getFormSingulation() != null && osepWipStatus.getFormSingulation().equalsIgnoreCase("0") == false)
                        {
                            assemblyLot = (AssemblyLot) m_assemblyDataMap.get(lotNumber + partNumber);

                            if (assemblyLot.getQtyIn() != null)
                            {
                                try
                                {
                                    assemblyLot.setQtyIn((Integer.parseInt(assemblyLot.getQtyIn()) + Integer.parseInt(osepWipStatus.getFormSingulation())) + "");
                                }
                                catch (Exception e)
                                {
                                    assemblyLot.setQtyIn(osepWipStatus.getFormSingulation());
                                }
                            }
                            else
                            {
                                assemblyLot.setQtyIn(osepWipStatus.getFormSingulation());
                            }

                            if (assemblyLot.getStage() != null)
                            {
                                assemblyLot.setStage(assemblyLot.getStage() + ", Form Singulation");
                            }
                            else
                            {
                                assemblyLot.setStage("Form Singulation");
                            }
                        }

                        assemblyLot.setDeviceName(partNumber);
                        assemblyLot.setPackageType(osepWipStatus.getPkgType());
                        assemblyLot.setLotNumber(lotNumber);
                        assemblyLot.setDateCode(osepWipStatus.getDateCode());
                        assemblyLot.setPONumber(osepWipStatus.getPoNo());
                        assemblyLot.setStatus(LOT_STATUS_RUNNING);
                        assemblyLot.setVendorName(VENDOR_NAME_OSEP);
                        assemblyLot.setFabLotNumber(fablotNumber);
                        assemblyLot.setCategory(LOT_CATEGORY_TYPE_PROD);
                        assemblyLot.setDateIn(dateIn);
                        assemblyLot.setExpectedDateOut( assyExpdateOut );
                        assemblyLot.setVendorLotNumber( releaseNumber );    // Release number Considering as Vendor Lot No
                    }
                    /*Fetching Test Lots*/
                    if (osepWipStatus.getBufferStock() != null && osepWipStatus.getBufferStock().equalsIgnoreCase("0") == false
                            || osepWipStatus.getFinalTest() != null && osepWipStatus.getFinalTest().equalsIgnoreCase("0") == false )
                    {


                        partNumber = NewAdaptorDAO.getPartNumber(fgPartNumber, LOCATION_TYPE_FT, WIP_TYPE_TEST);

                        if (partNumber == null)
                        {
                            partNumber = fgPartNumber;
                        }

                        testLot = (TestLot) m_ftDataMap.get(lotNumber + partNumber);

                        if (testLot == null)
                        {
                            testLot = new TestLot(VENDOR_NAME_OSEP);
                            m_ftDataMap.put(lotNumber + partNumber, testLot);
                        }

                        if (osepWipStatus.getBufferStock() != null && osepWipStatus.getBufferStock().equalsIgnoreCase("0") == false)
                        {
                            testLot = (TestLot) m_ftDataMap.get(lotNumber + partNumber);

                            if (testLot.getQtyIn() != null)
                            {
                                try
                                {
                                    testLot.setQtyIn((Integer.parseInt(testLot.getQtyIn()) + Integer.parseInt(osepWipStatus.getBufferStock())) + "");
                                }
                                catch (Exception e)
                                {
                                    testLot.setQtyIn(osepWipStatus.getBufferStock());
                                }
                            }
                            else
                            {
                                testLot.setQtyIn(osepWipStatus.getBufferStock());
                            }

                            if (testLot.getStage() != null)
                            {
                                testLot.setStage(testLot.getStage() + ", Buffer Stock");
                            }
                            else
                            {
                                testLot.setStage("Buffer Stock");
                            }
                        }
                        if (osepWipStatus.getFinalTest() != null && osepWipStatus.getFinalTest().equalsIgnoreCase("0") == false)
                        {
                            testLot = (TestLot) m_ftDataMap.get(lotNumber + partNumber);

                            if (testLot.getQtyIn() != null)
                            {
                                try
                                {
                                    testLot.setQtyIn((Integer.parseInt(testLot.getQtyIn()) + Integer.parseInt(osepWipStatus.getFinalTest())) + "");
                                }
                                catch (Exception e)
                                {
                                    testLot.setQtyIn(osepWipStatus.getFinalTest());
                                }
                            }
                            else
                            {
                                testLot.setQtyIn(osepWipStatus.getFinalTest());
                            }

                            if (testLot.getStage() != null)
                            {
                                testLot.setStage(testLot.getStage() + ", Final Test");
                            }
                            else
                            {
                                testLot.setStage("Final Test");
                            }
                        }
                        testLot.setPartNumber(partNumber);
                        testLot.setPackageType(osepWipStatus.getPkgType());
                        testLot.setLotNumber(lotNumber);
                        testLot.setDateCode(osepWipStatus.getDateCode());
                        testLot.setPoNumber(osepWipStatus.getPoNo());
                        testLot.setStatus(LOT_STATUS_RUNNING);
                        testLot.setPsType(LOCATION_TYPE_FT);
                        testLot.setCategory(LOT_CATEGORY_TYPE_PROD);
                        testLot.setFabLotNumber(fablotNumber);
                        testLot.setDateIn(dateIn);
                        testLot.setVendorLot( releaseNumber );

                    }
                    /*For fetching FG Lots*/
                    if( osepWipStatus.getFgBal() != null && osepWipStatus.getFgBal().equalsIgnoreCase("0") == false )
                    {
                        inventoryLot = (InventoryLot) m_fgInvDataMap.get(lotNumber + fgPartNumber);
                        if (inventoryLot == null) {
                            inventoryLot = new InventoryLot(VENDOR_NAME_OSEP, LOCATION_TYPE_FG);
                            m_fgInvDataMap.put(lotNumber + fgPartNumber, inventoryLot);
                        }

                        int quantity = 0;
                        if (inventoryLot.getQtyIn() != null) {
                            try {
                                quantity = Integer.parseInt(inventoryLot.getQtyIn());
                            }
                            catch (NumberFormatException ignore) {
                            }
                            quantity += fgQqtyIn;
                        } else {
                            quantity = fgQqtyIn;
                        }

                        if ( quantity > 0 )
                        {
                            inventoryLot.setPartNumber(fgPartNumber);
                            inventoryLot.setLotNumber(lotNumber);
                            inventoryLot.setFabLotNumber(fablotNumber);
                            inventoryLot.setQtyIn(quantity + "");
                            inventoryLot.setDateCode(osepWipStatus.getDateCode());
                            inventoryLot.setStatus(LOT_STATUS_RUNNING);
                            inventoryLot.setLotCategory(LOT_CATEGORY_TYPE_PROD);
                            inventoryLot.setDateIn(dateIn);
                            inventoryLot.setVendorLot( releaseNumber );
                        }

                    }

                    /* Here Fetching tape and Reel Lots*/
                    if( osepWipStatus.getFinalVisualInspection() != null && osepWipStatus.getFinalVisualInspection().equalsIgnoreCase("0") == false )
                    {

                        inventoryLot = (InventoryLot) m_tapereelDataMap.get(lotNumber + fgPartNumber);
                        if (inventoryLot == null)
                        {
                            inventoryLot = new InventoryLot();
                            m_tapereelDataMap.put(lotNumber + fgPartNumber, inventoryLot);
                        }

                        int quantity = 0;
                        if (inventoryLot.getQtyIn() != null)
                        {
                            try
                            {
                                quantity = Integer.parseInt(inventoryLot.getQtyIn());
                            }
                            catch (NumberFormatException ignore)
                            {
                            }
                            try
                            {
                                quantity += Integer.parseInt(osepWipStatus.getFinalVisualInspection());
                            }
                            catch(NumberFormatException npe)
                            {

                            }
                        }
                        else
                        {
                            try
                            {
                                quantity = Integer.parseInt(osepWipStatus.getFinalVisualInspection());
                            }
                            catch(NumberFormatException npe)
                            {

                            }
                        }
                        if ( quantity > 0 )
                        {
                            inventoryLot.setPartNumber(fgPartNumber);
                            inventoryLot.setLotNumber(lotNumber);
                            inventoryLot.setFabLotNumber(fablotNumber);
                            inventoryLot.setQtyIn(quantity + "");
                            inventoryLot.setDateCode(osepWipStatus.getDateCode());
                            inventoryLot.setStatus(LOT_STATUS_RUNNING);
                            inventoryLot.setVendorName(VENDOR_NAME_OSEP);
                            inventoryLot.setType(LOCATION_TYPE_CLASS_STORE);
                            inventoryLot.setLotCategory(LOT_CATEGORY_TYPE_PROD);
                            inventoryLot.setDateIn(dateIn);
                            inventoryLot.setVendorLot( releaseNumber );
                        }
                    }
                }
            }
        }
        catch (Exception e)
        {
           e.printStackTrace();

           log("ERROR!ERROR! While parsing the OSEP Details" + e);
           System.out.println("ERROR!ERROR! While parsing the OSEP Details" + e);
           throw e;
        }
    }

     public void getDDPIWipStatusInfoList( ArrayList allWipLotList )  throws Exception
    {
        String partNumber            = null;
        String lotNumber             = null;
        String fablotNumber          = null;
        OSEPWipStatus osepWipStatus  = null;

        InventoryLot inventoryLot    = null;


        try
        {
            Iterator osepIterator = allWipLotList.iterator();

            while (osepIterator.hasNext())
            {
                osepWipStatus = (OSEPWipStatus) osepIterator.next();

                partNumber    = osepWipStatus.getDevice();
                fablotNumber  = osepWipStatus.getFabLotNo();
                lotNumber     = osepWipStatus.getFabLotNo();


                if ( partNumber != null && lotNumber != null )
                {

                    /* Here Fetching tape and Reel Lots*/
                    if( osepWipStatus.getTprQty() != null && osepWipStatus.getTprQty().equalsIgnoreCase("0") == false )
                    {

                        inventoryLot = (InventoryLot) m_tapereelDataMap.get(lotNumber + partNumber);
                        if (inventoryLot == null)
                        {
                            inventoryLot = new InventoryLot();
                            m_tapereelDataMap.put(lotNumber + partNumber, inventoryLot);
                        }

                        int quantity = 0;
                        if (inventoryLot.getQtyIn() != null)
                        {
                            try
                            {
                                quantity = Integer.parseInt(inventoryLot.getQtyIn());
                            }
                            catch (NumberFormatException ignore)
                            {
                            }
                            try
                            {
                                quantity += Integer.parseInt(osepWipStatus.getTprQty() );
                            }
                            catch(NumberFormatException npe)
                            {

                            }
                        }
                        else
                        {
                            try
                            {
                                quantity = Integer.parseInt(osepWipStatus.getTprQty());
                            }
                            catch(NumberFormatException npe)
                            {

                            }
                        }
                        
                        if ( quantity > 0 )
                        {
                            inventoryLot.setPartNumber(partNumber);
                            inventoryLot.setLotNumber(lotNumber);
                            inventoryLot.setFabLotNumber(fablotNumber);
                            inventoryLot.setQtyIn(quantity + "");
                            inventoryLot.setDateCode(osepWipStatus.getDateCode());
                            inventoryLot.setStatus(LOT_STATUS_RUNNING);
                            inventoryLot.setVendorName(VENDOR_NAME_OSEP);
                            inventoryLot.setType(LOCATION_TYPE_CLASS_STORE);
                            inventoryLot.setLotCategory(LOT_CATEGORY_TYPE_PROD);
                            inventoryLot.setExpectedDate( osepWipStatus.getAssyODate()  );
                            inventoryLot.setDateIn(osepWipStatus.getRcvdDate() );
                            inventoryLot.setPkgType( osepWipStatus.getPkgType()  );

                        }

                    }
                }
            }
        }
        catch (Exception e)
        {
           e.printStackTrace();

           log("ERROR!ERROR! While parsing the OSEP DDPI Details" + e);
           System.out.println("ERROR!ERROR! While parsing the OSEP DDPI Details" + e);
           throw e;
        }
    }

    /**
     *
     * @param fileName
     * @return
     * @throws Exception
     */
    private ArrayList parseOSEPWip(String fileName, String sheetName) throws Exception
    {
        OSEPWipStatus osetWipStatus = null;
        ArrayList osetWipList       = new ArrayList();
        Sheet sheet                 = null;
        String checkValue           = null;

        if (fileName == null)
        {
            throw new ScalarException("Filename argument is null");
        }

        try
        {
            File wipStatusFile = new File(fileName);
            if (wipStatusFile.exists() == false)
            {
                throw new ScalarException(fileName + " doesnt exist");
            }

            log("\nFound " + fileName);
            log("Parsing the file for OSEP WIP Report...");
            System.out.println("\nFound " + fileName);
            System.out.println("Parsing the file for OSEP WIP Report...");

            Workbook workbook = Workbook.getWorkbook(wipStatusFile);

            sheet = workbook.getSheet(sheetName);

            Cell[] row = null;

            for (int rowCount = 8; rowCount < sheet.getRows(); rowCount++)
            {
                row = sheet.getRow(rowCount);
                
                if (row != null && row.length > 15)
                {
                    checkValue = row[0].getContents().trim();
                    if (checkValue != null )
                    {
                        osetWipStatus = new OSEPWipStatus();

                        if (row.length > 0)
                        {
                            if (row[0].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setDevice(null);
                            }
                            else
                            {
                                osetWipStatus.setDevice(row[0].getContents().trim());
                            }
                        }
                        if (row.length > 1)
                        {
                            if (row[1].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setPkgType(null);
                            }
                            else
                            {
                                osetWipStatus.setPkgType(row[1].getContents().trim());
                            }
                        }
                        if (row.length > 2)
                        {
                            if (row[2].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setLotNo(null);
                            }
                            else
                            {
                                osetWipStatus.setLotNo(row[2].getContents().trim());
                            }
                        }
                        if (row.length > 3)
                        {
                            if (row[3].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setFabLotNo(null);
                            }
                            else
                            {
                                osetWipStatus.setFabLotNo(row[3].getContents().trim());
                            }
                        }
                        if (row.length > 4)
                        {
                            if (row[4].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setDateCode(null);
                            }
                            else
                            {
                                osetWipStatus.setDateCode(row[4].getContents().trim());
                            }
                        }
                        if (row.length > 5)
                        {
                            if (row[5].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setPoNo(null);
                            }
                            else
                            {
                                osetWipStatus.setPoNo(row[5].getContents().trim());
                            }
                        }
                        if (row.length > 6)
                        {
                            if (row[6].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setInvQty(null);
                            }
                            else
                            {
                                osetWipStatus.setInvQty(row[6].getContents().trim());
                            }
                        }
                        if (row.length > 7)
                        {
                            if (row[7].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setWfrQty(null);
                            }
                            else
                            {
                                osetWipStatus.setWfrQty(row[7].getContents().trim());
                            }
                        }
                        if (row.length > 8)
                        {
                            if (row[8].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setWaferTest(null);
                            }
                            else
                            {
                                osetWipStatus.setWaferTest(row[8].getContents().trim());
                            }
                        }
                        if (row.length > 9)
                        {
                            if (row[9].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setWaferInk(null);
                            }
                            else
                            {
                                osetWipStatus.setWaferInk(row[9].getContents().trim());
                            }
                        }
                        if (row.length > 10)
                        {
                            if (row[10].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setStock(null);
                            }
                            else
                            {
                                osetWipStatus.setStock(row[10].getContents().trim());
                            }
                        }
                        if (row.length > 11)
                        {
                            if (row[11].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setVisualInspection(null);
                            }
                            else
                            {
                                osetWipStatus.setVisualInspection(row[11].getContents().trim());
                            }
                        }
                        if (row.length > 12)
                        {
                            if (row[12].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setDieAttach(null);
                            }
                            else
                            {
                                osetWipStatus.setDieAttach(row[12].getContents().trim());
                            }
                        }
                        if (row.length > 13)
                        {
                            if (row[13].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setWireBond(null);
                            }
                            else
                            {
                                osetWipStatus.setWireBond(row[13].getContents().trim());
                            }
                        }
                        if (row.length > 14)
                        {
                            if (row[14].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setPreMoldInspection(null);
                            }
                            else
                            {
                                osetWipStatus.setPreMoldInspection(row[14].getContents().trim());
                            }
                        }
                        if (row.length > 15)
                        {
                            if (row[15].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setMolding(null);
                            }
                            else
                            {
                                osetWipStatus.setMolding(row[15].getContents().trim());
                            }
                        }
                        if (row.length > 16)
                        {
                            if (row[16].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setPostMoldCure(null);
                            }
                            else
                            {
                                osetWipStatus.setPostMoldCure(row[16].getContents().trim());
                            }
                        }
                        if (row.length > 17)
                        {
                            if (row[17].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setDejunkTrim(null);
                            }
                            else
                            {
                                osetWipStatus.setDejunkTrim(row[17].getContents().trim());
                            }
                        }
                        if (row.length > 18)
                        {
                            if (row[18].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setSolderPlating(null);
                            }
                            else
                            {
                                osetWipStatus.setSolderPlating(row[18].getContents().trim());
                            }
                        }
                        if (row.length > 19)
                        {
                            if (row[19].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setFormSingulation(null);
                            }
                            else
                            {
                                osetWipStatus.setFormSingulation(row[19].getContents().trim());
                            }
                        }
                        if (row.length > 20)
                        {
                            if (row[20].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setBufferStock(null);
                            }
                            else
                            {
                                osetWipStatus.setBufferStock(row[20].getContents().trim());
                            }
                        }
                        if (row.length > 21)
                        {
                            if (row[21].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setFinalTest(null);
                            }
                            else
                            {
                                osetWipStatus.setFinalTest(row[21].getContents().trim());
                            }
                        }
                        if (row.length > 22)
                        {
                            if (row[22].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setFinalVisualInspection(null);
                            }
                            else
                            {
                                osetWipStatus.setFinalVisualInspection(row[22].getContents().trim());
                            }
                        }
                        if (row.length > 23)
                        {
                            if (row[23].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setFgBal(null);
                            }
                            else
                            {
                                osetWipStatus.setFgBal(row[23].getContents().trim());
                            }
                        }
                        if (row.length > 24)
                        {
                            if (row[24].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setRcvdDate(null);
                            }
                            else
                            {
                                osetWipStatus.setRcvdDate(row[24].getContents().trim());
                            }
                        }
                        if (row.length > 25)
                        {
                            if (row[25].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setInputDate(null);
                            }
                            else
                            {
                                osetWipStatus.setInputDate(row[25].getContents().trim());
                            }
                        }
                        if (row.length > 26)
                        {
                            if (row[26].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setAssyODate(null);
                            }
                            else
                            {
                                osetWipStatus.setAssyODate(row[26].getContents().trim());
                            }
                        }
                        if (row.length > 27)
                        {
                            if (row[27].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setRtnDate(null);
                            }
                            else
                            {
                                osetWipStatus.setRtnDate(row[27].getContents().trim());
                            }
                        }
                        if (row.length > 28)
                        {
                            if (row[28].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setrRtnDdate(null);
                            }
                            else
                            {
                                osetWipStatus.setrRtnDdate(row[28].getContents().trim());
                            }
                        }
                        if (row.length > 29)
                        {
                            if (row[29].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setCode(null);
                            }
                            else
                            {
                                osetWipStatus.setCode(row[29].getContents().trim());
                            }
                        }
                        if (row.length > 30)
                        {
                            if (row[30].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setCodeDescription(null);
                            }
                            else
                            {
                                osetWipStatus.setCodeDescription(row[30].getContents().trim());
                            }
                        }
                        if (row.length > 31)
                        {
                            if (row[31].getType().equals(CellType.EMPTY))
                            {
                                osetWipStatus.setProcessId(null);
                            }
                            else
                            {
                                osetWipStatus.setProcessId(row[31].getContents().trim());
                            }
                        }

                        osetWipList.add(osetWipStatus);
                    }
                }
            }
        }
        catch (Exception e)
        {
            throw new ScalarException("Exception " + e);
        }

        return osetWipList;
    }

    private ArrayList parseOSEPDDPIWip(String fileName, String sheetName) throws Exception
    {
        OSEPWipStatus osepWipStatus = null;
        ArrayList osepddpiWipList       = new ArrayList();
        Sheet sheet                 = null;

        if (fileName == null)
        {
            throw new ScalarException("Filename argument is null");
        }

        try
        {
            File wipStatusFile = new File(fileName);
            if ( wipStatusFile.exists() == false )
            {
                throw new ScalarException(fileName + " doesnt exist");
            }

            log("\nFound " + fileName);
            log("Parsing the file for OSEP DDPI WIP Report...");
            System.out.println("\nFound " + fileName);
            System.out.println("Parsing the file for OSEP DDPI WIP Report...");

            Workbook workbook = Workbook.getWorkbook( wipStatusFile );

            sheet = workbook.getSheet(sheetName);

            Cell[] row = null;

            for (int rowCount = 5; rowCount < sheet.getRows(); rowCount++)
            {
                row = sheet.getRow(rowCount);

                    osepWipStatus = new OSEPWipStatus();

                    if (row.length > 0)
                    {
                        if (row[0].getType().equals(CellType.EMPTY))
                        {
                            osepWipStatus.setRcvdDate(null);
                        }
                        else
                        {
                            int index = row[0].getContents().trim().lastIndexOf("/");
							osepWipStatus.setRcvdDate( row[0].getContents().trim().substring(0, index + 5)  );
                        }

                    }
                    // 1 is TIME
                    if (row.length > 2)
                    {
                        if (row[2].getType().equals(CellType.EMPTY) || row[2].getContents().trim().length() < 8 )
                        {
                            osepWipStatus.setAssyODate(null);  //Commit Date
                        }
                        else
                        {
                            int exIndex = row[2].getContents().trim().lastIndexOf("/");
                            osepWipStatus.setAssyODate( row[2].getContents().trim().substring(0, exIndex + 5)  );
                        }
                    }
                     // 3 is TIME
                    // 4 is Job Number
                    if (row.length > 5)
                    {
                        if (row[5].getType().equals(CellType.EMPTY))
                        {
                            osepWipStatus.setPkgType( null);
                        }
                        else
                        {
                            osepWipStatus.setPkgType(row[5].getContents().trim());
                        }
                    }
                    //6 is Customer
                    if (row.length > 7)
                    {
                        if (row[7].getType().equals(CellType.EMPTY))
                        {
                            osepWipStatus.setDevice(null);
                        }
                        else
                        {
                            osepWipStatus.setDevice(row[7].getContents().trim());
                        }
                    }
                    if (row.length >8)
                    {
                        if (row[8].getType().equals(CellType.EMPTY))
                        {
                            osepWipStatus.setFabLotNo(null);
                        }
                        else
                        {
                            osepWipStatus.setFabLotNo( row[8].getContents().trim() );
                        }
                    }
                    if (row.length > 9)
                    {
                        if (row[9].getType().equals(CellType.EMPTY))
                        {
                            osepWipStatus.setTprQty( null);
                        }
                        else
                        {
                            osepWipStatus.setTprQty(row[9].getContents().trim());
                        }
                    }
                    // 10 IS Proces Req Code
                    /*if (row.length > 11)
                    {
                        if (row[11].getType().equals(CellType.EMPTY))
                        {
                            osepWipStatus.setPoNo(null);
                        }
                        else
                        {
                            osepWipStatus.setPoNo(row[11].getContents().trim());
                        }
                    }*/
                    osepddpiWipList.add( osepWipStatus );
                }

        }
        catch (Exception e)
        {
            throw new ScalarException("Exception " + e);
        }

        return osepddpiWipList;
    }
    private void log(String message)
    {
        if (message == null) return;

        if (m_parserLogger != null)
        {
           synchronized (m_parserLogger)
           {
               m_parserLogger.logDebug(message + LINE_SEPARATOR);
           }
        }
        else
        {
           System.out.println(message);
        }
    }
}
